#include "BBVisibleScreenUtil.h"

CCRect BBVisibleScrren::m_Rect;

void BBVisibleScrren::lazyInit()
{
	if (m_Rect.size.width == 0.0f && m_Rect.size.height == 0.0f)
	{
		CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
		m_Rect.origin = pEGLView->getVisibleOrigin();
		m_Rect.size = pEGLView->getVisibleSize();
	}
}

CCRect BBVisibleScrren::GetSceneRect()
{
	lazyInit();
	return CCRectMake(m_Rect.origin.x, m_Rect.origin.y, m_Rect.size.width, m_Rect.size.height);
}


CCPoint BBVisibleScrren::LeftCenter()
{
	lazyInit();
	return ccp(m_Rect.origin.x, m_Rect.origin.y+m_Rect.size.height*.5);
}

CCPoint BBVisibleScrren::RightCenter()
{
	lazyInit();
	return ccp(m_Rect.origin.x+m_Rect.size.width, m_Rect.origin.y+m_Rect.size.height * .5);
}

CCPoint BBVisibleScrren::TopCenter()
{
	lazyInit();
	return ccp(m_Rect.origin.x+m_Rect.size.width*.5, m_Rect.origin.y+m_Rect.size.height);
}

CCPoint BBVisibleScrren::BottomCenter()
{
	lazyInit();
	return ccp(m_Rect.origin.x+m_Rect.size.width * .5, m_Rect.origin.y);
}

CCPoint BBVisibleScrren::Center()
{
	lazyInit();
	return ccp(m_Rect.origin.x+m_Rect.size.width * .5, m_Rect.origin.y+m_Rect.size.height * .5);
}

CCPoint BBVisibleScrren::LeftTop()
{
	lazyInit();
	return ccp(m_Rect.origin.x, m_Rect.origin.y+m_Rect.size.height);
}

CCPoint BBVisibleScrren::LeftBottom()
{
	lazyInit();
	return m_Rect.origin;
}

CCPoint BBVisibleScrren::RightBottom()
{
	lazyInit();
	return ccp(m_Rect.origin.x+m_Rect.size.width, m_Rect.origin.y);
}

CCPoint BBVisibleScrren::RightTop()
{
	lazyInit();
	return ccp(m_Rect.origin.x+m_Rect.size.width, m_Rect.origin.y+m_Rect.size.height);
}